package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.platform.dto.system.SystemMainContactDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.system.SystemMainContact;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class SystemMainContactConverter {

    public static SystemMainContactDto do2Dto(SystemMainContact domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return SystemMainContactMapper.INSTANCE.do2Dto(domain);
    }

    public static List<SystemMainContactDto> do2Dto(List<SystemMainContact> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(SystemMainContactConverter::do2Dto).collect(Collectors.toList());
    }

    public static SystemMainContact dto2Do(SystemMainContactDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return SystemMainContactMapper.INSTANCE.dto2Do(dto);
    }

    public static List<SystemMainContact> dto2Do(List<SystemMainContactDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(SystemMainContactConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface SystemMainContactMapper {

        SystemMainContactMapper INSTANCE = Mappers.getMapper(SystemMainContactMapper.class);

        SystemMainContactDto do2Dto(SystemMainContact domain);

        List<SystemMainContactDto> do2Dto(List<SystemMainContact> domain);

        SystemMainContact dto2Do(SystemMainContactDto dto);

        List<SystemMainContact> dto2Do(List<SystemMainContactDto> dto);
    }
}
